﻿using TLogger = Beeflys.Logger;

namespace Beeflys
{
    public abstract partial class AActor
    {
        class ActorLogger : ILogger
        {
            public ActorLogger(AActor actor)
            {
                this.actor = actor;
            }

            private AActor actor;

            public bool IsEnabled(LogLevel level)
            {
                return TLogger.Current.IsEnabled(level);
            }

            public void Info(string text)
            {
                TLogger.Current.Info(this.JointLogText(text));
            }

            public void Warn(string text)
            {
                TLogger.Current.Warn(this.JointLogText(text));
            }

            public void Debug(string text)
            {
                TLogger.Current.Debug(this.JointLogText(text));
            }

            public void Error(string text)
            {
                TLogger.Current.Error(this.JointLogText(text));
            }

            private string JointLogText(string text)
            {
                return $"[{this.actor.id.FullAddress}]=>{text}";
            }
        }
    }
}